<template>
  <div>
    <el-card>
      <div slot="header">
        <span>{{ type == 1 ? "订单详情" : "订单编辑" }}</span>
      </div>
      <div>
        <el-form label-width="100px" size="small">
          <el-form-item label="订单ID:">
            <template>
              <span>{{ form.id }}</span>
            </template>
          </el-form-item>
          <el-form-item label="订单编号:">
            <template>
              <span>{{ form.orderNo }}</span>
            </template>
          </el-form-item>
          <el-form-item label="下单时间:">
            <template>
              <span>{{ form.orderTime | handleTime }}</span>
            </template>
          </el-form-item>
          <el-form-item label="联系电话:">
            <el-input v-if="type == 2" v-model="form.phone"></el-input>
            <span v-else>{{ form.phone }}</span>
          </el-form-item>
          <el-form-item label="收货人:">
            <el-input v-if="type == 2" v-model="form.consignee"></el-input>
            <span v-else>{{ form.consignee }}</span>
          </el-form-item>
          <el-form-item label="收货地址:">
            <el-input v-if="type == 2" v-model="form.deliverAddress"></el-input>
            <span v-else>{{ form.deliverAddress }}</span>
          </el-form-item>
          <el-form-item label="送达时间:">
            <el-input v-if="type == 2" v-model="form.deliveryTime"></el-input>
            <span v-else>{{ form.deliveryTime }}</span>
          </el-form-item>
          <el-form-item label="用户备注:">
            <el-input v-if="type == 2" v-model="form.remarks"></el-input>
            <span v-else>{{ form.remarks }}</span>
          </el-form-item>
          <el-form-item label="订单金额:">
            <el-input v-if="type == 2" v-model="form.orderAmount"></el-input>
            <span v-else>{{ form.orderAmount }}</span>
          </el-form-item>
          <el-form-item label="订单状态:">
            <el-input v-if="type == 2" v-model="form.orderState"></el-input>
            <span v-else>{{ form.orderState }}</span>
          </el-form-item>
          <el-form-item>
            <el-button @click="$router.go(-1)">返回</el-button>
            <el-button type="primary" v-if="type == 2">保存</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
import { $_order_detail } from "@/api/order";
export default {
  data() {
    return {
      type: "",
      id: "",
      form: {},
    };
  },
  mounted() {
    this.type = this.$route.query.type;
    this.id = this.$route.query.id;
    $_order_detail({
      id: this.$route.query.id,
    }).then((res) => {
      console.log(29, res);
      this.form = res.data.data;
    });
  },
};
</script>

<style lang="less" scoped>
.el-input {
  width: 200px;
}
</style>